<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.prime.com.tr/ui">
    <f:metadata>
        <f:viewParam name="userid" value="#{frontController.userID}" valueChangeListener="#{frontController.logIn}"/>
        <f:viewParam name="advid" value="#{advertController.newAdvert.id}" valueChangeListener="#{advertController.loadNewAdvert}"/>
    </f:metadata>
    <ui:composition template="/template.xhtml">
        <ui:define name="title">
            #{localeController.translate("ShowAdv")}
        </ui:define>

        <ui:define name="body">
            <h:form id="newadvert" prependId="false">
                <p:panel>
                    <h:inputHidden id="recorded" value="#{advertController.recordAdvertToUserHistoty(advertController.newAdvert.id)}"/>
                    <h:inputHidden id="lat" value="#{advertController.newAdvert.lat}"/>
                    <h:inputHidden id="lng" value="#{advertController.newAdvert.lng}"/>
                    <h:outputLabel value="#{advertController.newAdvert.user.displayname}"/>
                    <table width="100%">
                        <tr>
                            <td><h:outputLabel value="Address on map"/></td>
                            <td><h:inputHidden id="address_input" value="#{advertController.newAdvert.address}"/>
                                <p:inputText id="address" value="#{advertController.newAdvert.address}" onchange="changedEdit()"/><p:button id="editadr" value="EditAddr" onclick="pressEdit();return false" />
                            </td>
                        </tr>

                        <tr id="rooms">
                            <td width="20%">
                                <h:outputLabel value="RoomsCount" />
                            </td>
                            <td >
                                <p:selectOneMenu id="RoomsSelector" value="#{advertController.newAdvert.room_count}" styleClass="label_width" >  
                                    <f:selectItem itemLabel="1 room" itemValue="1" />  
                                    <f:selectItem itemLabel="2 rooms" itemValue="2" />  
                                    <f:selectItem itemLabel="3 rooms" itemValue="3" /> 
                                    <f:selectItem itemLabel="4+ roms" itemValue="3" /> 
                                    <f:selectItem itemLabel="room in app" itemValue="-1" />  
                                </p:selectOneMenu>
                            </td>
                        </tr>
                        <tr id="price">
                            <td width="20%">
                                <h:outputLabel value="Price" />
                            </td>
                            <td >
                                <h:outputLabel value="" />                                        
                                <p:inputText id="Price" value="#{advertController.newAdvert.price}"  size="2"/>  
                                <h:outputLabel value="'000$"/>
                            </td>
                        </tr>
                        <tr id="totalarea">
                            <td width="20%">
                                <h:outputLabel value="TotalArea" />
                            </td>
                            <td >
                                <h:outputLabel value="" />                                        
                                <p:inputText id="TotalArea" value="#{advertController.newAdvert.total_sqr}"  size="3"/>m<sup>2</sup>  
                            </td>
                        </tr>
                        <tr id="livingarea">
                            <td width="20%">
                                <h:outputLabel value="LivingArea" />
                            </td>
                            <td >
                                <h:outputLabel value="" />                                        
                                <p:inputText id="LivingArea" value="#{advertController.newAdvert.living_sqr}"  size="3"/>m<sup>2</sup>  
                            </td>
                        </tr>
                        <tr id="kitchenarea">
                            <td width="20%">
                                <h:outputLabel value="KitchenArea" />
                            </td>
                            <td >
                                <h:outputLabel value="" />                                        
                                <p:inputText id="KitchenArea" value="#{advertController.newAdvert.kitchen_sqr}"  size="3"/>m<sup>2</sup>  
                            </td>
                        </tr>
                        <tr id="balconarea">
                            <td width="20%">
                                <h:outputLabel value="BalonArea" />
                            </td>
                            <td >
                                <h:outputLabel value="" />                                        
                                <p:inputText id="BalconArea" value="#{advertController.newAdvert.balkony_sqr}"  size="3"/>m<sup>2</sup>  
                            </td>
                        </tr>

                        <tr id="flors">
                            <td width="20%">
                                <h:outputLabel value="Flor" />
                            </td>
                            <td >
                                <h:outputLabel value="" />
                                <p:inputText id="Flor" value="#{advertController.newAdvert.floor}"  size="2"/>  

                                <h:outputLabel value=" / flors " />
                                <p:inputText id="Flors" value="#{advertController.newAdvert.floors}" size="2"/>  
                            </td>
                        </tr>
                        <tr>
                            <td width="20%">
                                <h:outputLabel value="Notes" />
                            </td>
                            <td >
                                <p:inputTextarea id="notes" value="#{advertController.newAdvert.notes}" />
                            </td>
                        </tr>
                    </table>
                </p:panel>
                <p:galleria id="gal" value="#{advertController.newAdvert.files}" var="image"
                            transitionInterval="0"
                            frameHeight="50"
                            frameWidth="50"
                            panelHeight="0"
                            panelWidth="300"
                            
                            >
                    <p:graphicImage 
                        value="/upload/#{image.userName.name}/#{image.name}" 
                        width="50" 
                        height="50"
                        /> 
                    <p:galleriaContent>
                        <p:graphicImage value="/upload/#{image.userName.name}/#{image.name}" width="50" height="50"  /> 
                    </p:galleriaContent> 

                </p:galleria>                            
            </h:form>
        </ui:define>
    </ui:composition>
</html>
